Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(report/dot): adds ability to match arrays for conditional coloring #882

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

sverweij
Copy link
Owner

@sverweij sverweij commented Dec 6, 2023

Description

  • adds ability to match arrays for conditional coloring on the dot reporter's theming

Motivation and Context

So it's possible to add formatting based on array like properties (like dependencyTypes) and to have a convenient way to match against multiple criteria at the same time.

How Has This Been Tested?

  • green ci
  • additional automated non-regression tests

Screenshots

E.g. to color based on types of aliased dependency types like this:

colored-by-dependency-types

(from the reproduction example for #863 on https://github.com/sverweij/dependency-cruiser-repro-repo/tree/main/863)

... you can use this configuration that uses most features enabled by this PR:

/** @type {import('dependency-cruiser').IConfiguration} */
module.exports = {
  options: {
    doNotFollow: { path: "node_modules" },
    moduleSystems: ["es6", "cjs"],
    tsPreCompilationDeps: true,
    combinedDependencies: true,
    tsConfig: { fileName: "tsconfig.json" },
    reporterOptions: {
      dot: {
        theme: {
          graph: {
            rankdir: "TD",
            splines: "ortho",
          },
          dependencies: [
            {
              // if the dependency type is one of the tsconfig type aliases ...
              criteria: {
                dependencyTypes: [
                  "aliased-tsconfig-",
                  "aliased-tsconfig-base-url",
                ],
              },
              // ... color the line teal
              attributes: { color: "blue" },
            },
            {
              criteria: { dependencyTypes: ["aliased-workspace"] },
              attributes: { color: "purple" },
            },
            {
              // if you just want one of the dependency types to match, a string suffices
              criteria: { dependencyTypes: "aliased-subpath-import" },
              attributes: { color: "green" },
            },
          ],
        },
      },
    },
  },
};

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation only change
  • Refactor (non-breaking change which fixes an issue without changing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • 📖

    • My change doesn't require a documentation update, or ...
    • it does and I have updated it
  • ⚖️

    • The contribution will be subject to The MIT license, and I'm OK with that.
    • The contribution is my own original work.
    • I am ok with the stuff in CONTRIBUTING.md.

Copy link

codeclimate bot commented Dec 6, 2023

Code Climate has analyzed commit 64eb79d and detected 0 issues on this pull request.

View more on Code Climate.

@sverweij sverweij merged commit 7abbe47 into main Dec 6, 2023
10 checks passed
@sverweij sverweij deleted the feature/adds-array-matching-to-dot-criteria branch December 6, 2023 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant